<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title>课工场论坛列表</title>
    <link href="css/bbs.css" rel="stylesheet">
<!--  <script src="js/forum.js" type="text/javascript" charset="utf-8"></script>-->
</head>
<body>
<div class="bbs">
    <header><span onclick="fatie()">我要发帖</span></header>
        <script type="text/javascript">
    	function fatie(){
    		document.getElementById("lastone").style.display="block";
    	}
    </script>
    
    <section>
        <ul></ul>
    </section>
    <div class="post" id="lastone">
        <input class="title" id = "title"; placeholder="请输入标题（1-50个字符）">
        所属版块：<select id="banben"><option>请选择版块</option><option>电子书籍</option><option>新课来了</option><option>新手报到</option><option>职业规划</option></select>
        <textarea class="content"></textarea>
        <input class="btn" value="发布" onclick="fabu()">
    </div>
    </div>
    <script type="text/javascript">
    	
    	function fabu(){
    		
    		document.getElementById("lastone").style.display="none";
    		var tou = new Array("images/tou01.jpg", "images/tou02.jpg", "images/tou03.jpg", "images/tou04.jpg");
    		var li = document.createElement("li");
    		var img = document.createElement("img");
    		document.getElementsByTagName("section")[0].style.display = "inline-block";
    		var bName = document.getElementsByTagName("section")[0].firstElementChild;
    		var aa = Math.ceil(Math.random()*4)-1;
    		var aaa = parseInt(aa);
    		img.setAttribute("src",tou[aaa]);
    		var div = document.createElement("div");
    		div.appendChild(img);
    		li.appendChild(div);
    		var titleH1 = document.createElement("h1");
    		var title = document.getElementById("title").value;
    		titleH1.innerHTML = title + "<br/>";
    		li.appendChild(titleH1);
    		var bankuai = document.createElement("p");
    		var neirong = document.getElementById("banben").value;
    		  var date=new Date();// 时间
    var year=date.getFullYear();
    var mothed=date.getMonth()+1;
    var day=date.getDate();
    var ss=date.getMinutes();
    var hh=date.getHours();
    var dat=year+"-"+mothed+"-"+day+"  "+hh+":"+ss;// 生成时间格式
    		bankuai.innerHTML = "版块：" + neirong + "    " + "时间：" +dat ;
    		li.appendChild(bankuai);
//  		bName.appendChild(li);
    		bName.insertBefore(li,bName.firstChild);
    			document.getElementById("lastone").style.display="none";
    			 document.getElementsByClassName("title")[0].value="";
    document.getElementsByClassName("banben")[0].value="0";
    document.getElementsByClassName("content")[0].value="0";
    			
    		
    	}
    	
    </script>

</body>
</html>
